<?php
	/**
	 * represents a connection to a mysql database which can handle simple actions
	 * @author Marcel
	 */
	class con {
		
		private $host;
		private $port;
		private $user;
		private $pass;
		private $dbasename;
		public $con;
		/**
		 * represents a connection to a mysql database which can handle simple actions
		 * @param String $host the ip of the host
		 * @param int $port the MySQL port(3306 by default)
		 * @param String $user the database user
		 * @param String $pass the password
		 * @param String $dbname the name of the database to use
		 */
		public function __construct( $host, $port, $user, $pass, $dbname){
			//$this->con = mysql_connect(sprintf("%s:%d", $host, $port), $user, $pass);
			$this->con = mysql_connect("localhost", "root", "");
			mysql_query(sprintf("use %s;", $dbname), $this->con);
		}
		
		public function get($table, $id, $col){
			$res = mysql_query(sprintf("SELECT %s FROM %s WHERE id = %d", $col, $table, $id));
			if($res == true){
				$dbobj = mysql_fetch_object($res);
				if($dbobj != false){
					return $dbobj;
				}else{
					return null;
				}
			}
		}
	}
?>